package team.first.movieapiv3.util;

import org.neo4j.ogm.config.Configuration;
import org.neo4j.ogm.session.Session;
import org.neo4j.ogm.session.SessionFactory;

/**
 * @Author: HAPPY
 * @Project_name: project
 * @Package_name: team.first.movieapiv3.util
 * @Date: 2021/12/22 13:02
 * @Description:
 */
public class SessionFactoryUtil {
    // 数据库的连接信息
    static Configuration configuration;

    static {
        configuration = new Configuration.Builder()
                .uri("bolt://localhost")
                .credentials("neo4j", "123456")
                .build();
    }

    /**
     * 获取SessionFactory对象
     * @param packages 要扫描的包路径
     * @return 返回SessionFactory
     */
    public static SessionFactory getSessionFactory(String packages) {
        return new SessionFactory(configuration, packages);
    }


    public static Session getSession(String packages) {
        return new SessionFactory(configuration, packages).openSession();
    }
}
